package com.situ.fly.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.situ.fly.util.UploadUtil;

/**
 * 负责上传文件
 * @author bobzyh
 *
 */
@Controller
public class UploadController {

	/**
	 * 上传接口
	 */
	@PostMapping("/upload")
	@ResponseBody
	public Object upload(MultipartFile file) {
		
		// 将文件保存到硬盘上 d:\img
		String fileName = UploadUtil.save(file, "d:\\img\\");
		
		
		Map<String, Object> result = new HashMap<String, Object>();
		// 状态 
		result.put("status", 0);
		result.put("msg", "图片上传成功");
		result.put("url", fileName);
		result.put("furl", "/upload/"+fileName);
		
		return result;
	}
}




